<template>
	<view>
		<view class="initial-Share-view">
			<view class="padding-30 margin-top13">
				<!-- 轮播图 -->
				<u-swiper :list="list" :height="400" bg-color="#C62F23" border-radius="20"></u-swiper>
			</view>
		</view>
		<!-- 加入梦创物联后领取 -->
		<view class="padding-30">
			<line-title name="加入梦创物联后领取"></line-title>
		</view>
		<!-- 商品列表 -->
		<view class="padding-30">
			<shop-goodsa :list="giftList" isList @goodsClick="receiveCourtesy"></shop-goodsa>
		</view>
		
		<!-- 抽奖弹窗 -->
		<popup-view :popupObject="popupObject" :popShow="show" @clickShow="popUpViewShow"></popup-view>
		<!-- 实名认证弹窗 -->
		<popup-view :popupObject="popupObject1" :popShow="show1" @clickShow="popUpViewShow1"></popup-view>
	</view>
</template>

<script>
	import lineTitle from "@/components/title/line-title.vue"
	import bottomButton from "@/components/button/bottomButton.vue"
	import shopGoodsa from "@/components/goods/shopGoodsa.vue"
	import popupView from "@/components/popup/popup-view.vue"
	export default {
		components:{
			lineTitle,
			bottomButton,
			shopGoodsa,
			popupView
		},
		data() {
			return {
				list: ['../../static/index/22.jpg', '../../static/index/22.jpg'],
				giftList: [],
				// 弹窗
				show: false,
				popupObject:{
					title:'恭喜',
					desc:'领取成功',
					btn:'确认',
					tips:'可在个人中心>新春红包中查看'
				},
				show1: false,
				popupObject1:{
					title:'请完成',
					desc:'实名认证',
					btn:'去认证',
					tips:''
				},
				userInfo:{}
			}
		},
		onShow() {
			this.getCourtesy()
			this.getUserInfo()
		},
		methods:{
			getCourtesy(){
				let value = new Date().getTime() / 1000
				this.$http.post(this.$api.getCourtesy,{},{token:true}).then(res=>{
					this.giftList = res.data.map(item=>{
						return {
							id:item.id,
							status:item.status,
							goods_image: item.img,
							goods_name: item.name,
							goods_desc: item.ageing - value,
							goods_price:item.amount,
							benName:"领取",
							type:value>item.ageing?'0':'1'
						}
					})
				})
			},
			getUserInfo() {
				this.$http.post(this.$api.getUserInfo, {}, {
					token: true
				}).then(res => {
					this.userInfo = res.data
				})
			},
			popUpViewShow(status){
				this.show = status
			},
			popUpViewShow1(status){
				this.show1 = status
				this.$tools.navigateTo('/pages/index/index-list/real-name')
			},
			receiveCourtesy(item){
				// 判断是否实名认证
				if(this.userInfo.is_auth !== 1){
					return this.show1 = true
				}
				this.$http.post(this.$api.receiveCourtesy,{id:item.id},{token:true}).then(res=>{
					if(res.code == 1){
						this.show = true
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	// 头部
	.initial-Share-view {
		width: 100%;
		height: 550rpx;
		background: url('../../static/index/18.png')no-repeat;
		background-size: 100% 100%;
		overflow: hidden;
	}
	.margin-top13 {
		margin-top: 80rpx;
	}
	.coin-image{
		width: 100%;
		height: 1200rpx;
	}
	.coin-info{
		background-color: #FFF0CA;
		padding: 30rpx;
		border-radius: 0rpx 0rpx 30rpx 30rpx;
	}
	.coin-info-text{
		font-size: 15px;
		color: #333333;
		margin-bottom: 20rpx;
	}
	.coin-info-text1{
		font-size: 14px;
		color: #C52B21;
	}
</style>